package com.cn.gxa.redisutils.config;

import com.cn.gxa.redisutils.intercept.LoginIntercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginInterceptConfig  implements WebMvcConfigurer {
    @Autowired
    private   LoginIntercept  loginIntercept;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("--配置--Intercept");
        //注册到springmvc 的Intercept 拦截器中
        InterceptorRegistration  registration=registry.addInterceptor(loginIntercept);
        //拦截哪些 放行哪些?

        registration.excludePathPatterns("/sortFindAll");//跳登录页面
        registration.excludePathPatterns("/save");//跳登录页面
        registration.excludePathPatterns("/toLogin");//跳登录页面
        registration.excludePathPatterns("/login");//连接数据库检查用户存在
        registration.excludePathPatterns("/login.html");//页面
        registration.excludePathPatterns("/img/**","/css/**","/**/**.js");
        //img  css  js
        registration.addPathPatterns("/**");

    }
}
